use std::cmp;

pub struct Row{
    strings:String,
}
impl From<&str> for Row{
    /**
     * 实现trai from 
     */
    fn from(slice:&str)->Self{
        Self{
            strings:String::from(slice),
        }
    }
}
impl Row {
    /**
     * 额。。怎么说呢，
     * 将字符串截断，按照传入的'start','end'
     */
    pub fn render(&self,start:usize,end:usize)->String{
        let end=cmp::min(end, self.strings.len());
        let start=cmp::min(start, end);
        self.strings.get(start..end).unwrap_or_default().to_string()
    }

    /**
     * 返回当前行的长度
     */
    pub fn len(&self)->usize{
        self.strings.len()
    }
    /**
     * 返回当前行是否为空
     */
    pub fn is_empty(&self)->bool{
        self.strings.is_empty()
    }
}